package com.sqx.modules.course.controller;

import com.sqx.common.utils.Result;
import com.sqx.modules.course.entity.Ads;
import com.sqx.modules.course.service.AdsService;
import com.sqx.modules.sys.controller.AbstractController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RestController
@Api(value = "广告信息", tags = {"广告信息"})
@RequestMapping(value = "/ads")
public class AdsController extends AbstractController {
    @Autowired
    private AdsService adsService;

    @ApiOperation("添加广告信息")
    @PostMapping("/addAds")
    public Result addAds(@RequestBody Ads ads) {
        adsService.addAds(ads);
        return Result.success().put("msg", "添加成功");
    }

    @PostMapping("/updateAds")
    @ApiOperation("修改广告信息")
    public Result updateAds(@RequestBody Ads ads) {
        adsService.updateAds(ads);
        return Result.success().put("msg", "更新成功");
    }

    @ApiOperation("查询广告信息列表")
    @GetMapping("/selectAdsList")
    public Result selectAdsList(@ApiParam("页数")Integer page,@ApiParam("条数")Integer limit,@ApiParam("广告id")Integer adsId, @ApiParam("广告名称")String adsName){
        return adsService.selectAdsList(page,limit,adsId, adsName);
    }

    @GetMapping("/selectAdsById")
    @ApiOperation("根据id查询广告信息")
    public Result selectAdsById(@ApiParam("广告id")Integer adsId){
        return adsService.selectAdsById(adsId);
    }

    @PostMapping("/deleteAds")
    @ApiOperation("删除广告信息")
    public Result deleteAds(@ApiParam("广告id")Integer[] adsIds){
        return adsService.deleteAds(adsIds);
    }

}
